package com.ruoyi.lvlian.domain;

import java.math.BigDecimal;

import com.alibaba.excel.annotation.ExcelProperty;
import com.ruoyi.common.core.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;

@Data
@ToString
@ApiModel(value = "产品对象", description = "产品对象")
public class Product  {
    private static final long serialVersionUID = 1L;

    private String id;
    private String productId;


    /** 购买方入库货品名称 */
    @ApiModelProperty(value = "购买方入库货品名称")
    private String name;

    /** 商品标题 */
    @ApiModelProperty(value = "商品标题")
    private String title;

    /** 商品副标题 */
    @ApiModelProperty(value = "商品副标题")
    private String subtitle;

    /** 一级分类id */
    @Excel(name = "一级分类id")
    private Long categoryLevelId1;

    /** 二级分类id */
    @Excel(name = "二级分类id")
    private Long categoryLevelId2;

    /** 三级分类id */
    @Excel(name = "三级分类id")
    private Long categoryLevelId3;

    /** 一级分类名字 */
    @Excel(name = "一级分类名字")
    private String categoryLevelName1;

    /** 二级分类名字 */
    @Excel(name = "二级分类名字")
    private String categoryLevelName2;

    /** 三级分类名字 */
    @Excel(name = "三级分类名字")
    private String categoryLevelName3;

    /** 计量单位 */
    @ApiModelProperty(value = "计量单位")
    private String goodsUnit;

    /** 购买方入库单价 */
    @ApiModelProperty(value = "购买方入库单价")
    private BigDecimal unitPrice;

    /** 最低价格 */
    @ApiModelProperty(value = "最低价格")
    private BigDecimal unitPriceLow;

    /** 最高价格 */
    @ApiModelProperty(value = "最高价格")
    private BigDecimal unitPriceHigh;

    /**  价格区间 */
    @ApiModelProperty(value = " 价格区间")
    private String priceRange;

    /** 状态: 0-下架 1-上架 2-待审核 */
    @ApiModelProperty(value = "状态: 0-下架 1-上架 2-待审核")
    private String status;

    /** 主图URL */
    @ApiModelProperty(value = "主图URL")
    private String mainImage;

    /** $column.columnComment */
    private String createUser;

    /** $column.columnComment */
    private String createDate;

    /** 分类code */
    @ApiModelProperty(value = "分类code")
    private String categoryCode;

    /** 分类层级 */
    @ApiModelProperty(value = "分类层级")
    private String categoryLevel;

    /** 分类ids */
    @ApiModelProperty(value = "分类ids")
    private String[] categoryIdsArr;

    @ApiModelProperty(value = "分类名字s")
    private String[] categoryNamesArr;


    private String categoryIds; // 用于数据库存储的字符串形式

    @ExcelProperty("所属公司编码")
    @ApiModelProperty(value = "所属公司编码")
    private String orgCode;

    /** 商品编码 */
    @ApiModelProperty(value = "商品编码")
    private String code;
    @ApiModelProperty(value = "分类名字")
    private String categoryNames;

    public String getId() {
        if(StringUtils.isEmpty(productId)){
            return null;
        }else{
            id= productId;
        }
        return id;
    }

    public String getCategoryIds() {
        // 如果categoryIds为空但categoryIdsArr不为空，则从数组生成字符串
        if ((categoryIds == null || categoryIds.isEmpty()) &&
                categoryIdsArr != null && categoryIdsArr.length > 0) {
            this.categoryIds = String.join(",", categoryIdsArr);
        }
        return categoryIds;
    }

    // 只重写这一个方法
    public String[] getCategoryIdsArr() {
        // 如果categoryIdsArr为空，但categoryIds不为空，则把categoryIds转成数组赋值给categoryIdsArr
        if ((categoryIdsArr == null || categoryIdsArr.length == 0) &&
                categoryIds != null && !categoryIds.trim().isEmpty()) {
            this.categoryIdsArr = categoryIds.split(",");
        }
        return categoryIdsArr;
    }

    public String getCategoryNames() {
        // 如果categoryNames为空，但categoryNamesArr不为空，则把categoryNamesArr转成字符串赋值给categoryNames
        if ((categoryNames == null || categoryNames.trim().isEmpty()) &&
                categoryNamesArr != null && categoryNamesArr.length > 0) {
            this.categoryNames = String.join(",", categoryNamesArr);
        }
        return categoryNames;
    }


    @ApiModelProperty(value = "备注")
    private String remark;
}
